package io;

import static net.mindview.util.Print.print;

import java.io.Externalizable;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

class Blip1MY implements Externalizable {
	public Blip1MY() {
		print("Blip1MY Constructor");
	}

	public void writeExternal(ObjectOutput out) throws IOException {
		print("Blip1MY.writeExternal");
	}

	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		print("Blip1MY.readExternal");
	}
}

class Blip2MY implements Externalizable {
	Blip2MY() {
		print("Blip2MY Constructor");
	}

	public void writeExternal(ObjectOutput out) throws IOException {
		print("Blip2MY.writeExternal");
	}

	public void readExternal(ObjectInput in) throws IOException,
			ClassNotFoundException {
		print("Blip2MY.readExternal");
	}
}

public class BlipsMY {
	public static void main(String[] args) throws IOException,
			ClassNotFoundException {
		print("Constructing objects:");
		Blip1MY b1 = new Blip1MY();
		Blip2MY b2 = new Blip2MY();
		ObjectOutputStream o = new ObjectOutputStream(new FileOutputStream(
				"BlipsMY.out"));
		print("Saving objects:");
		o.writeObject(b1);
		o.writeObject(b2);
		o.close();
		// Now get them back:
		ObjectInputStream in = new ObjectInputStream(new FileInputStream(
				"BlipsMY.out"));
		print("Recovering b1:");
		b1 = (Blip1MY) in.readObject();
		// OOPS! Throws an exception:
		// ! print("Recovering b2:");
		// ! b2 = (Blip2)in.readObject();
		
		//b2 = (Blip2MY)in.readObject();
		//
		in.close();
	}
}
